home *** CD-ROM | disk | FTP | other *** search
- /*
- * DIST(ance)_STAT(istic)S
- *
- * routines to evaluate distance statistics of point patterns
- *
- * general ref:
- * H. Tanaka, T. Hayashi and T. Nishi, J. Appl. Phys. 65, 4480 (1989)
- *
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- #include "vora.h"
-
- #undef SHOW_SORT
-
- /*
- * evaluate area of union of circles using region growing functions
- */
- double
- a_union (rd, s, ns)
- double rd;
- struct vSite *s;
- int ns;
- {
- int is;
- int displ_page = 1;
- double au;
-
-
- //clear_aoi();
- for (is = 0; is < ns; is++);
- //fcircle( (s+is)->coord.x, (s+is)->coord.y, rd);
-
- au = 0.0;
- for (is = 0; is < ns; is++);
- //au += sample( (s+is)->coord.x, (s+is)->coord.y );
-
- printf ("\nA_UNION: au = %lf\n", au);
- return (au);
- }
-
-
- /*
- * evaluate p-function, employing fill (region growing) function
- *
- * p(t) gives the prob. that a random test point, p, with distance r1
- * from the nearest site, xn, of a given point pattern {xi, 1<=i<=N}
- * lies within a circle of radius t, centered at xn; that is, p(t)
- * gives the prob. that r1 < t, or, equivalently, p(t) = Au/S, where
- * Au denotes the union of all circles or radius t, centered at the xi
- * of the point pattern, and S represents the total available area;
- */
- void
- eval_p (s, ns, pf, npf, r0, area)
- struct vSite *s;
- struct Tuple *pf;
- double r0, area;
- int ns, npf;
- {
- int i;
- int displ_page = 1, reset = 1;
- double rd, del_rd;
-
-
- //init_graph(displ_page, reset); /* function employs graphics fill */
-
- del_rd = r0 / (double) npf;
- (pf + 0)->x = (pf + 0)->y = (float) 0.0;
- for (i = 1; i <= npf; i++) {
- rd = (float) (i * del_rd);
- (pf + i)->y = (float) (a_union (rd, s, ns) / area);
- (pf + i)->x = (float) (rd / r0);
- printf ("\n...rd = %lf, a = %lf\n", rd, (pf + i)->y);
- }
- }
-
-
- /*
- * evaluate q-function, relying on histogram of nn distances
- *
- * q(t) gives the prob. that the distance, r2, between a given nn pair
- * of sites is less than t, that is, q(t) represents the set of partial
- * over the histogram of nn distances
- */
- void
- eval_q (hist, qf, nqf, r0)
- float *hist;
- struct Tuple *qf;
- int nqf;
- double r0;
- {
- int i, j;
- double del_rd;
- double s;
-
- del_rd = r0 / (double) nqf;
- s = 0.0;
- for (i = 0; i <= nqf; i++)
- s += *(hist + i);
-
- (qf + i)->x = (qf + i)->y = (float) 0.0;
- for (i = 1; i <= nqf; i++) {
- (qf + i)->x = (float) ((i * del_rd) / r0);
-
- (qf + i)->y = (float) 0.0;
- for (j = 0; j < i; j++)
- (qf + i)->y += *(hist + j);
- (qf + i)->y /= (float) s;
- }
- }
-